<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
//系统内容云
$return=array();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'text';
$show_types=$_RQ['show_types']?:';text;image;audio;video;file;miniprogram;news;other;';
$show_types=str_array($show_types);
$tabs=array();
foreach($show_types as $sv){
	$title=content_types()[$sv];
	$tabs[]=array('op'=>$sv,'title'=>$title);
}
$return['groups']=pdo_getall('core_account_content_group',array('type'=>$_SESSION['content_type'],'uniacid'=>$_SESSION['uniacid']));
if($_RQ['op']=='text'){
	$_RQ['type']='text';
	if($_RQ['type']){
		$_SESSION['content_type']=$_RQ['type'];
	}
	$_SESSION['content_type']=$_SESSION['content_type']?:'text';
	$return['params']=array('type'=>$_SESSION['content_type']);	
	$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>$_SESSION['content_type']);
	$group_id=intval($_RQ['group_id']);
	if($group_id){
		$params['group_id']=$group_id;
		$return['params']['group_id']=$group_id;
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby=array();
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['num']){
		$psize = $_RQ['num'];
	}else{
		$psize = 10;
	}
	$total='';
	$list=pdo_getslice('core_account_content',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['content'] = $item['content'] ? $item['content'] : cfc('tools')->substr($item['content'],0,56);
			//整理返回数据
			if($_RQ['many']){
				$item['res']=$item;
			}else{
				$item['res']=$item['id'];
			}
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'content','title'=>'内容','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'res','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='image'){
	$_RQ['type']='image';
	if($_RQ['type']){
		$_SESSION['content_type']=$_RQ['type'];
	}
	$_SESSION['content_type']=$_SESSION['content_type']?:'image';
	$return['params']=array('type'=>$_SESSION['content_type']);	
	$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>$_SESSION['content_type']);
	$group_id=intval($_RQ['group_id']);
	if($group_id){
		$params['group_id']=$group_id;
		$return['params']['group_id']=$group_id;
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby=array();
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['num']){
		$psize = $_RQ['num'];
	}else{
		$psize = 10;
	}
	$total='';
	$list=pdo_getslice('core_account_content',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['content'] = $item['content'] ? $item['content'] : cfc('tools')->substr($item['content'],0,56);
			//整理返回数据
			if($_RQ['many']){
				$item['res']=$item;
			}else{
				$item['res']=$item['id'];
			}
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'image','title'=>'图片','type'=>'image','show'=>array('type <>'=>'text')),
			array('name'=>'h5url','title'=>'链接','type'=>'string','show'=>array('type <>'=>'miniprogram')),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'res','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='audio'){
	$_RQ['type']='audio';
	if($_RQ['type']){
		$_SESSION['content_type']=$_RQ['type'];
	}
	$_SESSION['content_type']=$_SESSION['content_type']?:'audio';
	$return['params']=array('type'=>$_SESSION['content_type']);	
	$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>$_SESSION['content_type']);
	$group_id=intval($_RQ['group_id']);
	if($group_id){
		$params['group_id']=$group_id;
		$return['params']['group_id']=$group_id;
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby=array();
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['num']){
		$psize = $_RQ['num'];
	}else{
		$psize = 10;
	}
	$total='';
	$list=pdo_getslice('core_account_content',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['content'] = $item['content'] ? $item['content'] : cfc('tools')->substr($item['content'],0,56);
			//整理返回数据
			if($_RQ['many']){
				$item['res']=$item;
			}else{
				$item['res']=$item['id'];
			}
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'file','title'=>'地址','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'res','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='video'){
	$_RQ['type']='video';
	if($_RQ['type']){
		$_SESSION['content_type']=$_RQ['type'];
	}
	$_SESSION['content_type']=$_SESSION['content_type']?:'video';
	$return['params']=array('type'=>$_SESSION['content_type']);	
	$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>$_SESSION['content_type']);
	$group_id=intval($_RQ['group_id']);
	if($group_id){
		$params['group_id']=$group_id;
		$return['params']['group_id']=$group_id;
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby=array();
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['num']){
		$psize = $_RQ['num'];
	}else{
		$psize = 10;
	}
	$total='';
	$list=pdo_getslice('core_account_content',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['content'] = $item['content'] ? $item['content'] : cfc('tools')->substr($item['content'],0,56);
			//整理返回数据
			if($_RQ['many']){
				$item['res']=$item;
			}else{
				$item['res']=$item['id'];
			}
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'file','title'=>'地址','type'=>'string','show'=>array('type'=>'text')),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'res','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='file'){
	$_RQ['type']='file';
	if($_RQ['type']){
		$_SESSION['content_type']=$_RQ['type'];
	}
	$_SESSION['content_type']=$_SESSION['content_type']?:'file';
	$return['params']=array('type'=>$_SESSION['content_type']);	
	$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>$_SESSION['content_type']);
	$group_id=intval($_RQ['group_id']);
	if($group_id){
		$params['group_id']=$group_id;
		$return['params']['group_id']=$group_id;
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby=array();
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['num']){
		$psize = $_RQ['num'];
	}else{
		$psize = 10;
	}
	$total='';
	$list=pdo_getslice('core_account_content',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['content'] = $item['content'] ? $item['content'] : cfc('tools')->substr($item['content'],0,56);
			//整理返回数据
			if($_RQ['many']){
				$item['res']=$item;
			}else{
				$item['res']=$item['id'];
			}
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'file','title'=>'内容','type'=>'string','show'=>array('type'=>'text')),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'res','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='miniprogram'){
	$_RQ['type']='miniprogram';
	if($_RQ['type']){
		$_SESSION['content_type']=$_RQ['type'];
	}
	$_SESSION['content_type']=$_SESSION['content_type']?:'miniprogram';
	$return['params']=array('type'=>$_SESSION['content_type']);	
	$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>$_SESSION['content_type']);
	$group_id=intval($_RQ['group_id']);
	if($group_id){
		$params['group_id']=$group_id;
		$return['params']['group_id']=$group_id;
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby=array();
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['num']){
		$psize = $_RQ['num'];
	}else{
		$psize = 10;
	}
	$total='';
	$list=pdo_getslice('core_account_content',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['content'] = $item['content'] ? $item['content'] : cfc('tools')->substr($item['content'],0,56);
			//整理返回数据
			if($_RQ['many']){
				$item['res']=$item;
			}else{
				$item['res']=$item['id'];
			}
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'image','title'=>'图片','type'=>'image'),
			array('name'=>'wxappurl','title'=>'小程序路径','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'res','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='news'){
	$_RQ['type']='news';
	if($_RQ['type']){
		$_SESSION['content_type']=$_RQ['type'];
	}
	$_SESSION['content_type']=$_SESSION['content_type']?:'news';
	$return['params']=array('type'=>$_SESSION['content_type']);	
	$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>$_SESSION['content_type']);
	$group_id=intval($_RQ['group_id']);
	if($group_id){
		$params['group_id']=$group_id;
		$return['params']['group_id']=$group_id;
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby=array();
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['num']){
		$psize = $_RQ['num'];
	}else{
		$psize = 10;
	}
	$total='';
	$list=pdo_getslice('core_account_content',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['content'] = $item['content'] ? $item['content'] : cfc('tools')->substr($item['content'],0,56);
			//整理返回数据
			if($_RQ['many']){
				$item['res']=$item;
			}else{
				$item['res']=$item['id'];
			}
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'image','title'=>'图片','type'=>'image'),
			array('name'=>'h5url','title'=>'H5路径','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'res','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
?>

